home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / File Compare Vers & Date / MySimpleCompare.r < prev    next >
Encoding:
Text File  |  1996-09-30  |  5.6 KB  |  223 lines  |  [TEXT/MPS ]

  1. //
  2. //    MySimpleCompare.r
  3. //
  4. //    All files from this example are installed to folder "Simple Compare Example"
  5. //    on the root of the selected target volume of the installation.
  6. //
  7. //    This script demonstrates installing two test files, one based on creation 
  8. //    date comparison, the other based on version comparison against target file. 
  9. //    Date for source file, to be compared against target file, is specified in 
  10. //    the source file spec ('infs' ). The version number for source file, to be 
  11. //    compared against target file, is specified in the file atom ( 'infa' ).
  12. //
  13. //    To compare files by date specify 'useSrcCrDateToCompare' within file atom 
  14. //    ( 'infa' ), and to compare files by version specify 'useVersProcToCompare'.
  15. //
  16. //    See the "File Compare by Procedure" example for instructions on how
  17. //    to implement custom version comparison with the Installer.
  18. //
  19. //    NOTE: File versions and dates are ignored during Custom Remove.
  20. //
  21. //
  22. //    Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
  23. //
  24.  
  25. #include "InstallerTypes.r"
  26.  
  27. // • packages
  28.  
  29. // do a compare before installing based on the Creation date of 
  30. // target file against the date specified in the 'infs' resource
  31. resource 'inpk' (100) {
  32.     format0 {
  33.         showsOnCustom,
  34.         removable,
  35.         dontForceRestart,
  36.         0,
  37.         0,
  38.         "Example File to “Simple Compare Example” folder ( by creation date )",
  39.         {    
  40.             'infa', 1000
  41.         },
  42.     }
  43. };
  44.  
  45. // do a compare before installing based on the 'vers' (1) resource
  46. // of target against 'vers' value specified in 'infs' resource
  47. resource 'inpk' (200) {
  48.     format0 {
  49.         showsOnCustom,
  50.         removable,
  51.         dontForceRestart,
  52.         0,
  53.         0,
  54.         "Example File to “Simple Compare Example” folder ( by version )",
  55.         {    
  56.             'infa', 2000
  57.         },
  58.     }
  59. };
  60.  
  61.  
  62. // • file atoms
  63.  
  64. // creation date compare file atom ( date set in 'infs' )
  65. resource 'infa' (1000) {
  66.     format1 {
  67.         deleteWhenRemoving,
  68.         deleteWhenInstalling,
  69.         copy,                            
  70.         dontIgnoreLockedFile,
  71.         dontSetFileLocked,
  72.         useSrcCrDateToCompare,    //  • Use creation date for compare
  73.         srcNeedExist,
  74.         rsrcForkInRsrcFork,
  75.         
  76.         leaveAloneIfNewer,        //  if target file is newer:
  77.                                 //  Easy Install - skip installing file
  78.                                 //    Custom Install - ask "newer,older,cancel"
  79.         
  80.         updateExisting,            //  Update an existing file
  81.         copyIfNewOrUpdate,
  82.         rsrcFork,
  83.         dataFork,
  84.         0,                    // TARGET - size ( filled in by ScriptCheck )
  85.         0x0,                // Finder Attribute flags ( filled in by ScriptCheck )
  86.         10000,                // TARGET - file spec ( 'intf' )
  87.         {    
  88.             10000,            // SOURCE - file spec ( 'infs' )
  89.             0,                 
  90.             0                
  91.         },    
  92.         
  93.         0x0,                // • version number 
  94.                             // ( not used with 'useSrcCrDateToCompare' )
  95.                             
  96.         0,                    // 'invc' code resource - not used
  97.         0,                    // 'inex' code resource - not used
  98.         ""                    
  99.     }
  100. };
  101.  
  102. // simple version compare ( 'vers' (1) ) file atom
  103. resource 'infa' (2000) {
  104.     format1 {
  105.         deleteWhenRemoving,                
  106.         deleteWhenInstalling,            
  107.         copy,                            
  108.  
  109.         dontIgnoreLockedFile,            
  110.         dontSetFileLocked,                
  111.  
  112.         useVersProcToCompare,    // • use version resource for comparison
  113.                                 // - defaults to std version compare
  114.                                 // if no 'invc' code resource specifed below
  115.                                         
  116.         srcNeedNotExist,                
  117.         rsrcForkInRsrcFork,
  118.         leaveAloneIfNewer,        //  • if target file is newer:
  119.                                 //  Easy Install - skip installing file
  120.                                 //    Custom Install - ask "newer,older,cancel"
  121.  
  122.         updateExisting,                    
  123.         copyIfNewOrUpdate,                
  124.         
  125.         rsrcFork,
  126.         dataFork,
  127.  
  128.         0,                    // TARGET - size ( 0 filled in by ScriptCheck )
  129.         0x0,                // Finder Attribute flags ( 0x0 filled in by ScriptCheck )
  130.         20000,                // TARGET - file spec ( 'infs' )
  131.         {    
  132.             20000,            // SOURCE - file spec ( 'infs' )
  133.             0,                 
  134.             0                
  135.         },    
  136.         
  137.         0x0,                // • version number for comparisons
  138.                             // NOTE: this value is filled in by ScriptCheck
  139.                             // when value is set to 0x0 and
  140.                             // 'useVersProcToCompare' flag is specified
  141.                             
  142.         0,                    // 'invc' code resource - none used
  143.                             // • be sure this is set to zero to force
  144.                             // the Installer to use its default
  145.                             // version comparison method
  146.         
  147.         0,                    // 'inex' code resource - none used
  148.         ""                    // file atom description
  149.     }
  150. };
  151.  
  152.  
  153. // • creation date comparison file specs
  154.  
  155. // target file spec
  156. resource 'intf' (10000) {
  157.     format1 {
  158.         noSearchForFile,             // use default search path
  159.         TypeCrNeedNotMatch,         // target TYPE,CREATOR need not match
  160.         'ttro',                     // target TYPE ( ignored, see above )
  161.         'ttxt',                     // target CREATOR ( ignored, see above )
  162.         0,                             // finder attribute flags
  163.         
  164.         0x1,                          // creation date for new file or to compare
  165.                                     // with creation date of existing file.
  166.                                             
  167.         0x1,                          // modification date for new file
  168.                                     // ( filled by ScriptCheck if set to 1 )
  169.                                     // - this is only used when creating
  170.                                     // a new file, they are not used for
  171.                                     // comparisons.
  172.         
  173.         0,                             // search proc ID ( 'insp' )
  174.         
  175.         ":Simple Compare Example:Example File • comp by date"    
  176.                                     // path to target file
  177.         }
  178.     };
  179.  
  180. // source file spec
  181. resource 'infs' (10000) {
  182.     'ttro',                
  183.     'ttxt',                
  184.     0x1,
  185.     noSearchForFile,
  186.     TypeCrMustMatch,
  187.     "Disk 1:Example File • comp by date"
  188. };
  189.  
  190.  
  191.  
  192. // • version comparison file specs
  193.  
  194. // target file spec
  195. resource 'intf' (20000) {
  196.     format1 {
  197.         noSearchForFile,                     
  198.         TypeCrNeedNotMatch,                 
  199.         'ttro',                             
  200.         'ttxt',                             
  201.         0,                                         
  202.         0x1,                          // creation date for new file                                            
  203.         0x1,                          // modification date for new file
  204.                                     // ( value of 1 filled by ScriptCheck )
  205.                                     // - these are only used when creating
  206.                                     // a new file
  207.         0,    
  208.         ":Simple Compare Example:Example File • comp by vers"    
  209.                                     // path to target file
  210.         }
  211.     };
  212.  
  213. // source file spec
  214. resource 'infs' (20000) {
  215.     'ttro',                
  216.     'ttxt',                
  217.     0x1,
  218.     noSearchForFile,
  219.     TypeCrMustMatch,
  220.     "Disk 1:Example File • comp by vers"
  221. };
  222.  
  223.